{% extends "base.html" %}

{% block title %}Wiki - 知识库{% endblock %}

{% block content %}
<div class="container mt-4">
    <h1>Wiki 知识库</h1>
    <div class="d-flex justify-content-between align-items-center mb-3">
        <p>这里是社区共享的知识库，任何人都可以编辑和完善。</p>
        <a href="{{ url_for('edit_wiki_page', page_title='新页面') }}" class="btn btn-primary">
            <i class="fas fa-plus"></i> 创建新页面
        </a>
    </div>

    <div class="list-group">
        {% for page in pages %}
        <a href="{{ url_for('view_wiki_page', page_title=page.title) }}" class="list-group-item list-group-item-action">
            <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">{{ page.title }}</h5>
                <small>最后更新: {{ page.updated_at.strftime('%Y-%m-%d %H:%M') }}</small>
            </div>
            <p class="mb-1">{{ page.content|truncate(100) }}</p>
            <small>创建者: {{ page.author.username }}</small>
        </a>
        {% else %}
        <div class="alert alert-info">暂无Wiki页面，点击上方按钮创建第一个页面。</div>
        {% endfor %}
    </div>
</div>
{% endblock %}
